package com.qian.service.ddj.dao;

import com.qian.service.ddj.entity.DdjBusiness;
import com.yaowk.service.common.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

@Repository
public interface BusinessRepository extends BaseRepository<DdjBusiness, Integer> {

    @Modifying
    @Query(value = "update ddj_business set balance = balance + ?2 where id = ?1", nativeQuery = true)
    int increaseBalance(Integer businessId, BigDecimal balance);

    @Modifying
    @Query(value = "update ddj_business set balance = balance - ?2 where id = ?1", nativeQuery = true)
    int decreaseBalance(Integer businessId, BigDecimal balance);

    @Modifying
    @Query(value = "update ddj_business set backup1 = ?2 where id = ?1 and backup1 = ?3", nativeQuery = true)
    int updateCode(Integer id, String s, String code);
}
